﻿using System;

class SequenceOfGivenSum
{
    static void Main()
    {
        Console.Write("How long will be your array : ");
        int n = int.Parse(Console.ReadLine());
        int[] Array = new int[n];
        Console.WriteLine("Insert {0} integer", n);
        for (int i = 0; i < Array.Length; i++)
        {
            Console.Write("{0}:", i + 1);
            Array[i] = int.Parse(Console.ReadLine());
        }
        Console.Write("Insert searching sum - ");
        int s = int.Parse(Console.ReadLine());
        int NewSum = new int();
        int StartIndex = 0;
        int FinalIndex = 0;
        for (int i = 0; i < Array.Length - 1; i++)
        {
            NewSum = Array[i];
            for (int j = i + 1; j < Array.Length; j++)
            {
                NewSum += Array[j];
                if (NewSum == s)
                {
                    StartIndex = i;
                    FinalIndex = j;
                    Console.Write("Integers with sum = {0} have values : ", s);
                    for (int k = StartIndex; k <= FinalIndex; k++)
                    {
                        Console.Write("{0} ", Array[k]);
                    }

                    Console.WriteLine();
                }
            }
        }
        
    }
}
